﻿@{
    Layout = null;
    var options = new AjaxOptions()
    {
        Url = Url.Action("SiteConfigs", "SiteManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccess",
        OnFailure = "OnFailure",
        OnComplete = "OnComplete"        
    };
}
@Html.Partial("_MessageBox")
 @section scripts{
<script type="text/javascript">
    $(document).ready(function () {
        $('#PostIT').click(function () {
            $(this).parents('form').submit();
            return false;
        });

        $.validator.addMethod("regex",
                                function (value, element, regexp) {
                                    var re = new RegExp(regexp);
                                    return this.optional(element) || re.test(value);
                                },
                                "Please check email address."
                             );
        @{
            foreach (Century.Common.Enumerations.EmailConfigType type in Enum.GetValues(typeof(Century.Common.Enumerations.EmailConfigType))){
                <text>$("#@(type.ToString())").rules("add", { regex: /^[a-zA-Z0-9._-]+@("@")[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/ });</text>
            }
        }
    });

    function OnSuccess(data) {
        ReloadTree();
        OpenPopup('Message', 'Site data successfully saved.', false);
    }

    function OnFailure(data) {
        OpenPopup('Message', 'An error occured during save operation. <br/>Please try again or contact with administrator.', true);
    }

    function OnComplete(data) {
        // code here
    }
</script>
     }
@{Html.EnableClientValidation();}
@using (Ajax.BeginForm(options))
{
    <div style="text-align: left; min-height: 600px; margin-bottom: 20px;">
        <table border="0" cellspacing="0" cellpadding="0" class="advanced-tbl">
            <tr>
                <td colspan="2">
                    <h2>Country Site Properties</h2>
                    <br />
                    <img src="@Url.Content("~/Content/themes/admin/img/general/warning.png")" alt="Warning" />
                    Please don't change if you are not sure !<br />
                    <img src="@Url.Content("~/Content/themes/admin/img/general/warning.png")" alt="Warning" />
                    Your changes will be appear on <b>Live</b>. There is no draft or etc. version for
                    these properties
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h3>Contact Phone</h3>
                </td>
            </tr>
            <tr>
                <td>
                    <img src="@Url.Content("~/Content/themes/admin/img/general/telephone.png")" alt="Contact Phone" />
                </td>
                <td class="lbl">
                    @Html.TextBox(Century.Common.Config.SiteConfigKey.ContactPhone.ToString(), null, new { @class = "big", Value = Century.Globalization.SiteConfigReader.Instance.GetConfig(Century.Common.Config.SiteConfigKey.ContactPhone) })
                </td>
            </tr>
            @foreach (Century.Common.Enumerations.EmailConfigType type in Enum.GetValues(typeof(Century.Common.Enumerations.EmailConfigType)))
            {
                <tr>
                    <td colspan="2">
                        <h3>@type.ToString()</h3>
                    </td>
                </tr>
                <tr>
                    <td>
                        <img src="@Url.Content("~/Content/themes/admin/img/general/email_open.png")" alt="@(type.ToString()) Email" />
                    </td>
                    <td class="lbl">
                        @Html.TextBox(type.ToString(), null, new { @class = "big", Value = TempData[type.ToString()] })
                        @Html.ValidationMessage(type.ToString())
                     </td>
                </tr>
            }
            <tr style="height: 100px;">
                <td>
                    &nbsp;
                </td>
                <td class="lbl">
                    <input type="submit" value="Save" class="btn_green btn" />
                </td>
            </tr>
        </table>
    </div>
}